﻿<cfscript>
/** 
* ORM ProgramSchema
* 
* @hint "Hibernate persistenter t_schema. 各年级专业的培养方案 用于保存指定专业年级在规定学期修读的课程" 
* 
*/ 

component 
	displayname="public.service.orm.senate.ProgramSchema" 
	output=false 
	persistent=true 
	selectBeforeUpdate=true dynamicInsert=true dynamicUpdate=true 
	cacheuse="Transactional" 
	entityname="ProgramSchema" 
	table="t_schema"
	{

	property type="string" name="SchemaID" column="shm_id" fieldtype="id" generator="assigned" hint="培养方案序号";

	property type="string" name="Grade" column="grade" hint="年级";
	property type="string" name="Term" column="term_index" hint="计划开课学期";
	property type="string" name="AcademicYear" column="academic_year" hint="学年";
	property type="string" name="AcademicTerm" column="academic_term" hint="学期";
	
	property type="string" name="SchemaProps" column="shm_prop" hint="培养方案课程属性";

	property name="Subject" fieldtype="many-to-one" fkcolumn="sbj_id" cfc="Subject"  hint="专业";
	property name="Course" fieldtype="many-to-one" fkcolumn="cid" cfc="Course"  hint="课程";
	property name="CourseProperty" fieldtype="many-to-one" fkcolumn="prop_id" cfc="CourseProperty"  hint="课程属性";
	property name="CourseNature" fieldtype="many-to-one" fkcolumn="cna_id" cfc="CourseNature"  hint="课程性质";

	/**
	* @hint "自定义主键规则"
	* 
	* @Subject "专业"
	* @Grade "年级"
	* @Course "课程"
	*/
	public string function getID( required Subject, required string Grade, required Course ) output=false {
		
		var nextID = arguments.Grade & left(arguments.Subject.getSubjectID(), 5) & arguments.Subject.getSubjectDirection() & arguments.Course.getCourseID();

		/* 
			主键生成规则 
			
			培养方案号16位 4位为年级 + 5位专业代码 + 1位专业方向代码 + 6位课程号

			Unique: GRADE, SBJ_ID, CID
		*/
		return nextID;
	}
}

</cfscript>